<template>
	<view class="contain" style="height: 3000rpx;">
		<view v-for="(item,index) in list" :key="index" @click="change(index)">
			{{item}}
		</view>
	<van-button @click="goto">跳转页面</van-button>
	
	<navigator url="/pages/cate/index">跳转到cate页面</navigator>
	
	<child :title="title" @getMsg="getMsg"></child>
	
	<view class="">
		<view v-for="(item,index) in list" :key="index">
			{{item}}
		</view>
	</view>
	
	</view>
</template>

<script>
	import child from "../../components/child/child.vue"
	import {mapState} from "vuex"
	import {getBanner} from "../../request/api.js"
	export default {
		data() {
			return {
				title: 'Hello111',
				arr: [1, 2, 3]

			}
		},
		onLoad() {
			getBanner().then(res=>{
				console.log(res);
			})

		},
		computed:{
			// list(){
			// 	return this.$store.state.list
			// }
			//在计算属性中拿到vuex中state数据来用也可以用辅助函数
			
			...mapState(["list"])
			
			
		},
		methods: {
			goto(){
				let obj={
					id:5,
					name:"小明"
				}
				uni.navigateTo({
				
					url:"/pages/cate/index?obj="+JSON.stringify(obj)
				})
				//传多个参数的时候 要转化成字符串传递
			},
			getMsg(val){
				console.log(val);
				
			}
			
			
		},
		components:{
			child
		}
		
	
	}
</script>

<style lang="scss">
	.contain {
		// view{
		// 	background: red;
		// }
	}

	

</style>
